




//
//  MBNewsTableview.m
//  房源详情-小区详情
//
//  Created by MB__Lee on 2018/5/29.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBNewsTableview.h"
#import "MBFirstNewsCell.h"


@interface MBNewsTableview()<UITableViewDelegate,UITableViewDataSource>


@end

static NSString *MBFirstNewsCell_Identi = @"MBFirstNewsCell";

@implementation MBNewsTableview
-(NSMutableArray *)newsMut{
    if (!_newsMut) {
        _newsMut = [NSMutableArray array];
    }
    return  _newsMut;
}
-(void)news_addSource:(NSMutableArray *)source{
    [self.newsMut addObjectsFromArray:source];
    [self reloadData];
}

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    if (self = [super initWithFrame:frame style:style]) {
        self.delegate = self;
        self.dataSource = self;
        
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        [self registerNib:[UINib nibWithNibName:MBFirstNewsCell_Identi bundle:nil] forCellReuseIdentifier:MBFirstNewsCell_Identi];
    }
    return  self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  self.newsMut.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    MBFirstNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:MBFirstNewsCell_Identi];
    cell.model = self.newsMut[indexPath.row];
    cell.selectionStyle = UITableViewCellSeparatorStyleNone;
    return  cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (_newsBlock) {
        
        if (self.newsMut.count) {
            FirstNewModel *model =  self.newsMut[indexPath.row];
            _newsBlock(model.sn);
            
            
        }
        
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  115;
}

@end
